<?php include_once('header.php');?>
<div class="main-content">
		<div class="breadcrumbs" id="breadcrumbs">
			<script type="text/javascript">
				try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
			</script>
			<ul class="breadcrumb">
				<li><a href="/admin/welcome"><i class="icon-home home-icon"></i>首页</a></li>
				<li>反馈管理</li>
				<li>反馈列表</li>
			</ul>
		</div>	
		<div class="page-content" style="margin-top:8px;">
			<div class="visible-md visible-lg hidden-sm hidden-xs btn-group">
				<div style="float:left;margin-right:8px;">
					<?php if($authority['delete_status'] == 2) {?>
					<a onclick="selectAll()"><span class="btn btn-xs btn-inverse">全选/取消</span></a>
					<a onclick="deleteAll()"><span class="btn btn-xs btn-purple">删除选中</span></a>	
					<?php }?>		
				</div>
				<div style="float:right;">
					<form  action="/admin/opinion/opinion_list" method="post">
						<div style="float:left;">	
							用户名&nbsp;&nbsp;<input  type="text" id="username" name="username" placeholder="用户名" value="<?=$username?>" style="margin-right:20px;"/>								
							时间区间&nbsp;&nbsp;<input type="text" class="jcDate" id="ctime" name="ctime" readonly="readonly" value="<?=$ctime?>" style="background: #fff url(/public_source/www/assets/images/dateIco.png) no-repeat right center !important;" />
							- <input type="text" class="jcDate" id="etime" name="etime" readonly="readonly" value="<?=$etime?>" style="background: #fff url(/public_source/www/assets/images/dateIco.png) no-repeat right center !important;" />	
						</div>
						<a style="padding-left:10px;float:left;" id="search">
							<button type="submit" class="btn btn-xs btn-success">
								<i class="icon-search nav-search-icon "></i>搜索
							</button>
						</a>
					</form>
				</div>
				<div class="page-header" style="height:40px;"></div>
			</div>
			<div class="row">
				<div class="col-xs-12">
					<div class="table-header">
						反馈列表
					</div>
					<div class="table-responsive">
						<table id="sample-table-2" class="table table-striped table-bordered table-hover">
							<thead>
								<tr>
									<th>选择</th>
									<th>id</th>
									<th>用户名</th>
									<th>内容</th>
									<th>图片</th>
									<th>评论时间</th>
									<th>操作</th>
								</tr>
							</thead>
						</table>
					</div><!-- /.table-responsive -->
				</div><!-- /span -->
			</div>
		</div>														
	</div>
<?php include_once('content.php');?>
	<script src="/public_source/www/assets/js/jquery.dataTables.min.js"></script>
	<script src="/public_source/www/assets/js/jquery.dataTables.bootstrap.js"></script>
	<script src="/public_source/www/assets/js/jquery-confirm.js"></script>
	<script src="/public_source/www/assets/js/jQuery-jcDate.js"></script>
	<link href="/public_source/www/assets/css/jcDate.css" rel="stylesheet"/>
	<link  rel="stylesheet" href="/public_source/www/css/insure.css" />
	<link  rel="stylesheet" href="/public_source/www/assets/css/jquery-confirm.css" />
	<link  rel="stylesheet" href="/public_source/www/css/confirm.css" />
<?php include_once('footer.php');?>	
<script type="text/javascript">
	var message = <?php echo $message;?>;
	if(message == 2) {var con = '修改成功,请确定';}else if(message == 3){var con = '修改失败,请重试';}else if(message ==4){var con = '添加成功,请确认';}else {var con = '添加失败,请重试';};
	if(message != 1) {
		$.alert({
		    title: '提示',
		    content: con,
		    confirm: function(){
		    	window.location.replace('/admin/opinion/opinion_list');
		    }
		});
	}
	jQuery(function($) {
		var username = $("#username").val();
		var ctime = $("#ctime").val(); 
		var etime = $("#etime").val();  
		var oTable1 = $('#sample-table-2').dataTable({ 
	        "oLanguage": {
	                "sUrl": "/public_source/www/assets/language/zh_CN.json"
	         },			     	
			"aaSorting": [[ 5, "desc" ]],
			"bAutoWidth": true, 
			"bProcessing": true, //开启读取服务器数据时显示正在加载中……特别是大数据量的时候，开启此功能比较好
            "bServerSide": true, //开启服务器模式，使用服务器端处理配置datatable。注意：sAjaxSource参数也必须被给予为了给datatable源代码来获取所需的数据对于每个画。 这个翻译有点别扭。开启此模式后，你对datatables的每个操作 每页显示多少条记录、下一页、上一页、排序（表头）、搜索，这些都会传给服务器相应的值。 
            "sAjaxSource": "/admin/opinion/ajax_opinion_list?username="+username+"&ctime="+ctime+"&etime="+etime, //给服务器发请求的url
            "aoColumns": [ //这个属性下的设置会应用到所有列，按顺序没有是空
                {"mData": 'check'},
                {"mData": 'id'}, //mData 表示发请求时候本列的列明，返回的数据中相同下标名字的数据会填充到这一列
                {"mData": 'username'},
                {"mData": 'intro'},
                {"mData": 'litpics'},
                {"mData": 'create_time'},
                {"mData": 'operate'},
            ],
            "aoColumnDefs": [//和aoColums类似，但他可以给指定列附近爱属性
               {"bSortable": false, "aTargets": [0,4,6]},//这句话意思是第1,3,6,7,8,9列（从0开始算） 不能排序
        	]
		});
	});
</script>
<script  type="text/javascript">
	function selectAll() { //全选/取消
		var a = document.getElementsByName("c_id");
		if(a[0].checked){
			for(var i = 0;i<a.length;i++){
				if(a[i].type == "checkbox") a[i].checked = false;
			}
		}else{
			for(var i = 0;i<a.length;i++){
				if(a[i].type == "checkbox") a[i].checked = true;
			}
		}
	}

	//删除
	function deleteOne(a) {
		var id = $(a).attr('data_id');
		$.confirm({
		    title: '提示',
		    content: '确认要删除数据？',
		    confirm: function(){		    	
				data = {id:id};
				$.ajax({
					async: false,
					url:"/admin/opinion/delete",
					type:"post",
					data: data,
					dataType: 'json',
					success:function(data){
						var message = "删除失败,请重试!";
						if(data) {
							var message = "删除成功,请确认!";
						}
						$.alert({
						    title: '提示',
						    content: message,
						    confirm: function(){
								window.location.replace('/admin/opinion/opinion_list');
						    }
						});							
						return false; 
					}
				});
		    },
		    cancel: function(){
		    }
		});
	}
	function deleteAll() {//删除选中数据
		var str = document.getElementsByName("c_id");
		var objarray = str.length;
		var chestr="";
		for (i=0;i<objarray;i++) {
		  if(str[i].checked == true) {
		  	chestr+=str[i].value+",";
		  }
		}
		if(chestr == "") {
			$.alert({
			    title: '提示',
			    content: '请选择数据进行操作！',
			    confirm: function(){
			    }
			});
		}else { //ajax传值进行删除选中行的数据
			$.confirm({
			    title: '提示',
			    content: '确认要删除选中数据？',
			    confirm: function(){		    	
					data = {str:chestr};
					$.ajax({
						async: false,
						url:"/admin/opinion/delete_all",
						type:"post",
						data: data,
						dataType: 'json',
						success:function(data){
							var message = "删除失败,请重试!";
							if(data) {
								var message = "删除成功,请确认!";
							}
							$.alert({
							    title: '提示',
							    content: message,
							    confirm: function(){
									window.location.replace('/admin/opinion/opinion_list');
							    }
							});							
							return false; 
						}
					});
			    },
			    cancel: function(){
			    }
			});
		}
	}
</script>
<script type="text/javascript">
	$(function (){
		$("input.jcDate").jcDate({					       
			IcoClass : "jcDateIco",
			Event : "click",
			Speed : 100,
			Left : 0,
			Top : 28,
			format : "-",
			Timeout : 100
		});
	});
</script>	